<template>
  <el-dropdown trigger="click" @command="changeLanguage">
    <!-- 显示图标 -->
    <div>
      <svg-icon style="color: #fff; font-size: 20px" icon-class="language" />
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item :disabled="this.$i18n.locale === 'zh'" command="zh">
        中文
      </el-dropdown-item>
      <el-dropdown-item :disabled="this.$i18n.locale === 'en'" command="en">
        En
      </el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import Cookie from 'js-cookie'
export default {
  name: '',
  components: {},
  props: {},
  data() {
    return {

    }
  },

  computed: {},
  watch: {},
  created() { },
  mounted() { },
  methods: {
    changeLanguage(type) {
      // 设置类型 写入到cookie
      Cookie.set('language', type) // 写入缓存
      // 改变当前的多语言
      this.$i18n.locale = type // 讲当前的多语言类型改为type类型
      this.$message.success('切换语言成功')
    }
  }
}
</script>
<style lang='css' scoped>
</style>